package com.net.hash.equal;

public class Student 
{
   private String name;
   
   private int id;
   
   
   
   Student(String name, int id)
   {
	   this.name = name;
	   this.id = id;
   }
   

public String getName() {
	return name;
}

public void setName(String name) {
	this.name = name;
}

public int getId() {
	return id;
}

public void setId(int id) {
	this.id = id;
}
   

@Override
	public boolean equals(Object obj)
    {
		if(this == obj)
	     return true;
		
		if(obj == null || this.getClass() != obj.getClass())
	     return false;
		
		Student st = (Student)obj;
		
	
		return this.id == st.id && (this.name == st.name || (this.name != null && this.name.equals(st.getName())));
	}

 @Override
	public int hashCode()
    {
	   final int prime = 31;
	   int result =1;
	   result = prime * result + ((this.name ==null)?0:name.hashCode());
	   result = prime * result + id;
		return result;
	}
	
	
}
